define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {

            //用户id
            var uid = $("#uid").val()

            //记录ids
            var ids = $("#reids").val()

            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    //index_url: 'user_card/index' + location.search,
                    index_url: 'user_money_log/index?uid='+uid+'&ids='+ids,
                    add_url: 'user_money_log/add',
                    // edit_url: 'user_card/edit',
                   // del_url: 'chongzhi/del',
                    multi_url: 'user_money_log/multi',
                    table: 'user_card',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [

                        {checkbox: true},
                        {field: 'id', title: __('ID'),operate:false},
                        {field: 'nickname', title: '关联用户',operate:'like'},
                        {field: 'money', title: '变更值',operate:false},
                        {field: 'before', title: '变更前',operate:false},
                        {field: 'after', title: '变更后',operate:false},
                        {field: 'type', title: '交易类型',searchList:{"0":'微信支付',"1":'余额支付',"2":'小时卡',"3":'套餐'},formatter:Table.api.formatter.normal},
                        {field: 'typeText', title: '类型',operate:false},
                        {field: 'memo', title: '备注',operate:false},
                        {field: 'createtime', title:'记录时间', operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
